home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / bbs / pad311.zip / CHAR.MH < prev    next >
Text File  |  1996-08-21  |  3KB  |  106 lines

  1. // Defines various character related operations and operations between characters
  2. // and strings. See string.mh for string-related operations.
  3. //
  4. // Function list:
  5. //
  6. // bool         isDigit         (char: ch);
  7. // bool         isUpper         (char: ch);
  8. // bool         isLower         (char: ch);
  9. // char         upChar          (char: ch);
  10. // char         lowChar         (char: ch);
  11. // int          hexDig          (char: ch);
  12. // int          countChar       (string: source, char: toCount)
  13. // void         stripChar       (Ref string: source, char: toStrip)
  14. // void         appendChar      (Ref string: source, char: toAppend)
  15. // string       stripCharf      (string: source, char: toStrip)
  16. // string       appendCharf     (string: source, char: toAppend)
  17. //
  18. // void         charInit        ();
  19. // int          charToken       (string: token, string: params);
  20.  
  21. #ifndef __CHAR_MH
  22. #define __CHAR_MH
  23.  
  24. #ifndef __GENERAL_MH
  25. #include "general.mh"
  26. #endif
  27.  
  28. // isDigit returns true if the given character is a digit 
  29. // between 0 and 9.
  30.  
  31. //bool isDigit (char: ch) {
  32. //  bool: temp;
  33. //  print ("got here (char.mh)\n");
  34. //  getch ();
  35. //  temp := ((ch >= '0') and (ch <= '9'));
  36. //  if ((ch >= '0') and (ch <= '9')) {
  37. //    print ("returning true\n");
  38. //    getch ();
  39. //    vidsync ();
  40. //    temp := True;
  41. //    }
  42. //  else {
  43. //    print ("returning false\n");
  44. //    getch ();
  45. //    vidsync ();
  46. //    temp := False;
  47. //    };
  48. //  print ("left isDigit ()\n");
  49. //    }
  50. //  print ("endif");
  51. //  getch ();
  52. //  return temp;}
  53.  
  54. // isLower returns true if the given character is a lower case letter.
  55.  
  56. bool isLower (char: ch) {
  57.   return ((ch >= 'a') and (ch <= 'z'));}
  58.  
  59. // isUpper returns true if the given character is an upper case letter.
  60.  
  61. bool isUpper (char: ch) {return ((ch >= 'A') and (ch <= 'Z'));}
  62.  
  63.  
  64. // lowChar converts a character to its lower-case equivilant.
  65.  
  66. //char lowChar (char: ch) {
  67. //  if (isUpper (ch)) {return ch - 'A' + 'a';};
  68. //  return ch;
  69. //  }
  70.  
  71. // hexDig returns the value of a hexidecimal digit. Returns -1 if the
  72. // character is not a valid hex digit. Valid hex digits are 0..9,
  73. // a..f, and A..F. This function should return a value in the range
  74. // of 0..15 if the given character is a valid hex digit.
  75.  
  76. //int hexDig (char: hex) {
  77. //  if (isDigit (hex)) return hex - '0';
  78. //  if (isUpper (hex)) return hex - 'A' + 10;
  79. //  if (isLower (hex)) return hex - 'a' + 10;
  80. //  return -1;
  81. //  }
  82.  
  83. // Appends a character to a string, modifying the original string.
  84.  
  85. void appendChar (Ref string: theString, char: theChar) {
  86.   theString [strlen(theString)+1] := theChar;
  87.   }
  88.  
  89. // AppendCharf appends a char to a string without modifying the original
  90. // string. Returns the new string.
  91.  
  92. //string appendCharf (string: theString, char: theChar) {
  93. //  appendChar (theString, theChar);
  94. //  return theString;
  95. //  }
  96.  
  97. // stripCharf removes all occourances of a given character from a string. The
  98. // original string is not modified - the new string is returned by the function.
  99.  
  100. //string stripCharf (string: theString, char: ch) {
  101. //  stripChar (theString, ch);
  102. //  return theString;
  103. //  }
  104.  
  105. #endif
  106.